<h5>Interfacing the Wiring hardware and Pure Data pd~</h5>
<p>This tutorial introduces the basic interfacing between the Wiring hardware and and Pure Data <a href="http://puredata.info">http://puredata.info</a>. The brief for the tutorial will be to send  data to the Wiring board, the Wiring board will read the data and turn ON or OFF the board LED accordingly. It assumes the Wiring software and Pure Data are installed and the proper Wiring setup has been previously completed. For more Information on Wiring install check out the <a href="http://wiring.org.co/learning/tutorials/">tutorials</a> about Wiring installation and software setup.</p>
<h5>Step 1</h5>
<p>Copy and paste the following code on the Wiring editor: Verify your program is free of compiling errors by pressing the Compile/Verify button in the menu bar. Press the Upload button in the menu bar. In case of syntax errors the Wiring environment will print the error messages otherwise it will print the Upload was completed successfully, the uploading process triggers activity in the Rx/Tx LEDs on the Wiring hardware. The new program will start automatically after uploading. Use the Serial Monitor button to watch the data coming from the Wiring board, then close the Serial Monitor again.</p>
<pre>
int val;          // variable to receive data from the serial port
int ledpin = 48;  // Wiring board LED

void setup() 
{
  pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
  Serial.begin(9600);       // start serial communication at 9600bps
}

void loop() {
  if( Serial.available() )         // if data is available to read
  {
    val = Serial.read();           // read it and store it in 'val'
    if( val == 'H' )               // if 'H' was received
    {
      digitalWrite(ledpin, HIGH);  // turn ON the LED
    } 
    else if( val == 'L' ) { 
      digitalWrite(ledpin, LOW);   // otherwise turn it OFF
    }
  }
  delay(100);                      // wait 100ms for next reading
}
</pre>
<p>&nbsp;</p>
<h5>Step 2</h5>
<p>Next step is to setup things in Pure Data. Start Pure Data.</p>
<p>Note: The object &quot;comport&quot; has 2 attributes, the first one is the port number and the second one is the speed of the port which should match the speed set in the Wiring program.</p>
<p><img src="imgs/pd-06.png" width="862" height="581" /></p>
<p>&nbsp;</p>
<h5>Step 3</h5>
<p>Connect the objects as shown:
<code></code>
<p><img src="imgs/pd-07.png" width="862" height="581" /></p>
<p>&nbsp;</p>
<h5>Step 4</h5>
<p>Press the message &quot;devices&quot; to print in the console the available ports:</p>
<p><img src="imgs/pd-08.png" width="627" height="520" /></p>
<h5>Step 5</h5>
<p>  Set the right port in the list, automatically the port start to sending data. There is one toggle to send 'H' or 'L' to the board  making the Wiring board LED to blink.</p>
<p><img src="imgs/pd-09.png" width="862" height="581" /></p>
<p><img src="imgs/pd-10.png" width="862" height="581" /> </p>
<p>&nbsp;</p>
